package com.example.administrator.foodrowfresh.configs.classifyconfing.classifyadapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.example.administrator.foodrowfresh.R;
import com.example.administrator.foodrowfresh.configs.classifyconfing.classifyentity.MyClassifyDetailItemEntity;
import org.xutils.x;


/**
 * Created by lqr on 2016/5/4.
 */
public class MyClassifyViewPagerAdapter extends PagerAdapter {
    private MyClassifyDetailItemEntity.DataBean list;
    private Context mContext;
    public MyClassifyViewPagerAdapter(MyClassifyDetailItemEntity.DataBean list,Context mContext) {
        this.list = list;
        this.mContext=mContext;
    }

    @Override
    public int getCount() {
        return list.getBanner()==null?0:list.getBanner().size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view==object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view=View.inflate(mContext, R.layout.layout_detail_item_item,null);
        ImageView imageView= (ImageView) view.findViewById(R.id.detail_item_item);
        x.image().bind(imageView,list.getBanner().get(position).getImage());
        container.addView(view);
        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }
}
